export const useWujie = () => {
    const props: {
        appId?: string;
        gtag?: any;
        parentWindow?: Window; // 自定义
        selfWindow?: Window; // 自定义

        // 在无界的环境中，返回的是子应用的window.
        window?: Window; // 默认同 selfWindow

        // 如果正确匹配到子应用的iframe对象，则返回的是子应用的document,否则返回父容器的document
        document?: Document;
        location?: Location;
        localStorage?: Storage;
        sessionStorage?: Storage;
    } = window.$wujie?.props;
    if (window?.__POWERED_BY_WUJIE__ && props) {
        return {
            parentWindow: window.parent,
            selfWindow: props.window,
            ...props,
        };
    }
    return {
        appId: '',
        gtag: window?.gtag,
        parentWindow: window,
        selfWindow: window,
        window,
        document: window.document,
        location: window.location,
        localStorage: window.localStorage,
        sessionStorage: window.sessionStorage,
    };
};
